home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / blanker / source / blankers / main.c < prev    next >
C/C++ Source or Header  |  1993-08-01  |  2KB  |  84 lines

  1. /*
  2.  *    Copyright (c) 1993 Michael D. Bayne.
  3.  *    All rights reserved.
  4.  *
  5.  *    Please see the documentation accompanying the distribution for distribution and disclaimer information.
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <exec/ports.h>
  10. #include <exec/memory.h>
  11.  
  12. #include <dos/dos.h>
  13.  
  14. #include <clib/exec_protos.h>
  15. #include <clib/alib_protos.h>
  16.  
  17. #include "defs.h"
  18.  
  19. VOID blank( VOID );
  20. VOID defaults( struct bMessage * );
  21. VOID prefs( LONG );
  22. LONG winSig( VOID );
  23.  
  24. __far    extern    ULONG    RangeSeed;
  25. struct    MsgPort        *modPort, *sendPort;
  26. struct    bMessage    *bMsg;
  27. struct    Task        **Task;
  28.     ULONG        Depth, Mode, Type;
  29.     UBYTE        *prefData;
  30.  
  31. VOID main( VOID )
  32. {
  33.     LONG retval = CONTINUE, sigs;
  34.     struct bMessage *modMsg;
  35.  
  36.     if(( sendPort = FindPort( "BlankerCC" ))&&( modPort = CreatePort(0,0))&&
  37.         ( modMsg = AllocMem( sizeof( struct bMessage ), MEMF_PUBLIC|MEMF_CLEAR ))) {
  38.  
  39.         modMsg->bm_Mess.mn_ReplyPort = modPort;
  40.         modMsg->bm_Mess.mn_Length = sizeof( struct bMessage );
  41.         modMsg->bm_Task = FindTask( 0L );
  42.         Forbid();
  43.         CopyMem( "Blanker Task", modMsg->bm_Task->tc_Node.ln_Name, 13 );
  44.         Permit();
  45.         defaults( modMsg );
  46.         PutMsg( sendPort, ( struct Message * )modMsg );
  47.  
  48.         RangeSeed = ((ULONG)modMsg ^ (ULONG)sendPort );
  49.  
  50.         while( retval ) {
  51.             sigs = Wait( SIG_PORT | winSig() | SIGBREAKF_CTRL_C );
  52.  
  53.             if( sigs & winSig() ) prefs( IDCMP );
  54.             if( sigs & SIGBREAKF_CTRL_C ) retval = QUIT;
  55.             if(( sigs & SIG_PORT )||( bMsg )) {
  56.                 while( bMsg = ( struct bMessage * )GetMsg( modPort )) {
  57.                     Depth = bMsg->bm_Dep;
  58.                     Mode = bMsg->bm_Mod;
  59.                     prefData = bMsg->bm_Data;
  60.                     Type = bMsg->bm_Type;
  61.                     Task = (( struct Task ** )bMsg->bm_Task );
  62.                     ReplyMsg(( struct Message * )bMsg );
  63.                     bMsg = 0L;
  64.  
  65.                     switch( Type ) {
  66.                     case BM_DOBLANK:
  67.                         if( SetSignal( 0L, 0L ) & SIGBREAKF_CTRL_C ) SetSignal( 0L, SIGBREAKF_CTRL_C );
  68.                         else blank();
  69.                         break;
  70.                     case BM_DOPREFS:
  71.                         if(!( winSig() )) prefs( STARTUP );
  72.                         break;
  73.                     case BM_DOQUIT:
  74.                         if( winSig() ) prefs( KILL );
  75.                         retval = QUIT;
  76.                         break;
  77.                     }
  78.                 }
  79.             }
  80.         }
  81.     }
  82.     if( modPort ) DeletePort( modPort );
  83. }
  84.